package com.px.plan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.px.framework.aes.AesSecurityParameter;
import com.px.plan.domain.PlanMark;
import com.px.plan.service.IPlanMarkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.px.common.annotation.Log;
import com.px.common.core.controller.BaseController;
import com.px.common.core.domain.AjaxResult;
import com.px.common.enums.BusinessType;
import com.px.common.utils.poi.ExcelUtil;
import com.px.common.core.page.TableDataInfo;

/**
 * 预案区域Controller
 * 
 * @author WRJ
 * @date 2024-08
 */
@Api("飞行预案区域管理")
@RestController
@RequestMapping("/plan/mark")
public class PlanMarkController extends BaseController
{
    @Autowired
    private IPlanMarkService planMarkService;

    /**
     * 查询预案区域列表
     */
    @ApiOperation("飞行预案区域列表")
    @PreAuthorize("@ss.hasPermi('plan:mark:list')")
    @GetMapping("/list")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo list(PlanMark planMark)
    {
        startPage();
        List<PlanMark> list = planMarkService.selectPlanMarkList(planMark);
        return getDataTable(list);
    }

    /**
     * 导出预案区域列表
     */
    @ApiOperation("导出飞行预案区域")
    @PreAuthorize("@ss.hasPermi('plan:mark:export')")
    @Log(title = "预案区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AesSecurityParameter
    public void export(HttpServletResponse response, PlanMark planMark)
    {
        List<PlanMark> list = planMarkService.selectPlanMarkList(planMark);
        ExcelUtil<PlanMark> util = new ExcelUtil<PlanMark>(PlanMark.class);
        util.exportExcel(response, list, "预案区域数据");
    }

    /**
     * 获取预案区域详细信息
     */
    @ApiOperation("飞行预案区域详情")
    @PreAuthorize("@ss.hasPermi('plan:mark:query')")
    @GetMapping(value = "/{id}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(planMarkService.selectPlanMarkById(id));
    }

    /**
     * 新增预案区域
     */
    @ApiOperation("新增飞行预案区域")
    @PreAuthorize("@ss.hasPermi('plan:mark:add')")
    @Log(title = "预案区域", businessType = BusinessType.INSERT)
    @PostMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult add(@RequestBody PlanMark planMark)
    {
        return toAjax(planMarkService.insertPlanMark(planMark));
    }

    /**
     * 修改预案区域
     */
    @ApiOperation("修改飞行预案区域")
    @PreAuthorize("@ss.hasPermi('plan:mark:edit')")
    @Log(title = "预案区域", businessType = BusinessType.UPDATE)
    @PutMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult edit(@RequestBody PlanMark planMark)
    {
        return toAjax(planMarkService.updatePlanMark(planMark));
    }

    /**
     * 删除预案区域
     */
    @ApiOperation("删除飞行预案区域")
    @PreAuthorize("@ss.hasPermi('plan:mark:remove')")
    @Log(title = "预案区域", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(planMarkService.deletePlanMarkByIds(ids));
    }
}
